//var vdman = null;
//	vdman = new VDTable("vdman");
//	vdman.display();
// <div id="vdman" instancename="vdman" filename="C:\Temp\HTML5\canvas\canv\fmon\test.accdb"  style="display:none"></div>


var VFile = function(provided_filename)
{
	this.filename = provided_filename;
	var fu = new FileUtil();
	this.fileexists = fu.fileexists(this.filename);
	this.filesize = 0;
	this.lastwritetime = (new DateTimeUtil("1900/01/01")).yyyymmddhhmmss;
	this.name = "nothing";
	this.directory = "nothing";
	if(this.fileexists)
	{
		var myf = fu.fso.GetFile(this.filename);
		this.lastwritetime = (new DateTimeUtil(myf.DateLastModified)).yyyymmddhhmmss;
		this.filesize = myf.Size;
		this.name = myf.Name;
		this.directory = myf.ParentFolder.Path;
	}
}

var VFiles = function()
{
	this.items = new Array();
	this.items.length = 0;
	this.add = function(pobj)
	{
		this.items[this.items.length] = pobj;
		this.items.sort(this.sortcompare);
	}
	this.sortcompare = function(a, b)
	{
		if(a.name > b.name)
		{
			return 1;
		}
		else
		{
			return -1;
		}
	}
}

var VDirectoryManager = function(provided_filename)
{
	this.dbfilename = provided_filename;
	this.fu = new FileUtil();
	this.myname = (new MyNetwork()).username.toUpperCase();

	if(!this.fu.fileexists(this.dbfilename))
	{
		(new AccessApp()).createdbfile(this.dbfilename);
	}

	this.acc = new AccessClient(this.dbfilename);

	this.setuptables = function()
	{
		var sqll = new Array();
		sqll[sqll.length] = "create table VDirectories (VDID text(255), ForWhom text(255), VDName text(255), VDComment memo)";
		sqll[sqll.length] = "create table VDistributedDirectories (VPID text(255), VDID text(255), DirectoryPath memo)";
		this.acc.begintrans();
		for(var icnt = 0; icnt < sqll.length; icnt++)
		{
			this.acc.executenonquery(sqll[icnt]);
		}
		this.acc.committrans();
	}

	var rl = this.acc.getschema("tables");
	var tableexists = false;
	for(var rcnt = 0; rcnt < rl.length; rcnt++)
	{
		var re = rl[rcnt];
		tableexists = tableexists || (re.TABLE_NAME.toUpperCase() == "VDIRECTORIES");
	}

	if(!tableexists)
	{
		try
		{
			this.setuptables();
		}catch(err){}
	}

	this.acc = new AccessClient(this.dbfilename);
	this.localdbfilename = this.fu.gettempfilename(".accdb");

	this.refreshlocaldb = function()
	{
		this.fu.copyfile(this.dbfilename, this.localdbfilename);
		this.localacc = new AccessClient(this.localdbfilename);
	}
	this.getdirectorydefinition = function()
	{
		var sql = "select * from VDirectories where ForWhom is null or ForWhom = '" + this.myname + "' order by VDName";
		return this.localacc.executeselectquery(sql);
	}
	this.getdistributeddefinition = function()
	{
		var sql = "select * from VDistributedDirectories order by DirectoryPath";
		return this.localacc.executeselectquery(sql);
	}

	this.refresh = function()
	{
		this.refreshlocaldb();
		this.directories = this.getdirectorydefinition();
		this.distributeddirectories = this.getdistributeddefinition();
	}
	this.refresh();

	this.getdistributeddirectories = function(provided_vdid)
	{
		var ret = new Array();
		ret.length = 0;
		for(var icnt = 0; icnt < this.distributeddirectories.length; icnt++)
		{
			var de = this.distributeddirectories[icnt];
			if(de.VDID == provided_vdid)
			{
				ret[ret.length] = de;
			}
		}
		return ret;
	}

	this.generateid = function()
	{
		var dtu = new DateTimeUtil();
		var ret = dtu.yearstr + dtu.monthstr + dtu.daystr + dtu.hourstr + dtu.minutestr + dtu.secondstr + dtu.millisecondstr;
		ret += (new MyNetwork()).username.toUpperCase();
		return ret;
	}

	this.createdirectory = function(provided_name, provided_comment)
	{
		var sql = "insert into VDirectories (VDID, ForWhom, VDName, VDComment) values ('" + this.generateid() + "','" + this.myname + "','" + provided_name + "','" + provided_comment + "')";
		this.acc.executenonquery(sql);
		this.refresh();
	}

	this.modifydirectory = function(provided_vdid, provided_name, provided_comment)
	{
		var sql = "update VDirectories set VDName = '" + provided_name + "', VDComment = '" + provided_comment + "' where VDID = '" + provided_vdid + "'";
		this.acc.executenonquery(sql);
		this.refresh();
	}

	this.removedirectory = function(provided_vdid)
	{
		this.acc.begintrans();
		var sqll = new Array();
		sqll.length = 0;
		sqll[sqll.length] = "delete * from VDirectories where VDID = '" + provided_vdid + "'";
		sqll[sqll.length] = "delete * from VDistributedDirectories where VDID = '" + provided_vdid + "'";
		for(var icnt = 0; icnt < sqll.length; icnt++)
		{
			this.acc.executenonquery(sqll[icnt]);
		}
		this.acc.committrans();
		this.refresh();
	}

	this.adddistributeddirectory = function(provided_vdid, provided_path)
	{
		var sql = "insert into VDistributedDirectories (VPID, VDID, DirectoryPath) values ('" + this.generateid() + "','" + provided_vdid + "','" + provided_path + "')";
		this.acc.executenonquery(sql);
		this.refresh();
	}

	this.removedistributeddirectory = function(provided_vpid)
	{
		var sql = "delete * from VDistributedDirectories where VPID = '" + provided_vpid + "'";
		this.acc.executenonquery(sql);
		this.refresh();
	}

	this.publishdirectory = function(provided_vdid)
	{
		var sql = "update VDirectories set ForWhom = null where VDID = '" + provided_vdid + "'";
		this.acc.executenonquery(sql);
		this.refresh();
	}

	this.unpublishdirectory = function(provided_vdid)
	{
		var sql = "update VDirectories set ForWhom = '" + this.myname + "' where VDID = '" + provided_vdid + "'";
		this.acc.executenonquery(sql);
		this.refresh();
	}
}

var VDTable = function(pid)
{
	this.rootid = pid;
	this.rootnode = document.getElementById(this.rootid);
	this.instancename = this.rootnode.getAttribute("instancename");
	this.dbfilename = this.rootnode.getAttribute("filename");
	this.vdman = new VDirectoryManager(this.dbfilename);

	this.foldertableareaid = this.instancename + "foldertable" + (new Date()).getTime().toString();
	this.curtainid = this.instancename + "curtain" + (new Date()).getTime().toString();
	this.formid = this.instancename + "form" + (new Date()).getTime().toString();
	this.messagedivid = this.instancename + "messagediv" + (new Date()).getTime().toString();
	this.messageareaid = this.instancename + "messagearea" + (new Date()).getTime().toString();

	this.vdcreationform = new VDCreationForm(this.instancename, this.formid);
	this.vddirectoryform = new VDDirectoryForm(this.instancename, this.formid);
	this.vddescriptionform = new VDDescriptionForm(this.instancename, this.formid);

	this.reloadall = function()
	{
		this.vdman.refresh();
		this.display();
	}

	this.display = function()
	{
		this.rootnode.innerHTML = "";
		var t = this.rootnode.appendChild(document.createElement("table"));
		t.style.fontSize = "small";
		var r = t.appendChild(document.createElement("tr"));
		var d = r.appendChild(document.createElement("td"));
		var innert = d.appendChild(document.createElement("table"));
		var innerr = innert.appendChild(document.createElement("tr"));
		var innerd = innerr.appendChild(document.createElement("td"));
		innerd.style.color = "blue";
		innerd.innerText = "... create library ...";
		innerd.setAttribute("onclick", this.instancename + ".displaycreationform();");

		innerd = innerr.appendChild(document.createElement("td"));
		innerd.style.color = "blue";
		innerd.innerText = "... reload ...";
		innerd.setAttribute("onclick", this.instancename + ".reloadall();");

		r = t.appendChild(document.createElement("tr"));
		d = r.appendChild(document.createElement("td"));
		d.setAttribute("id", this.foldertableareaid);
		this.displayfoldertable();
	}

	this.displayfoldertable = function()
	{
		var mya = document.getElementById(this.foldertableareaid);
		mya.innerHTML = "";
		var t = mya.appendChild(document.createElement("table"));
		for(var icnt = 0; icnt < this.vdman.directories.length; icnt++)
		{
			var rid = this.instancename + icnt.toString() + (new Date()).getTime().toString() + "folderr";
			var did = rid + "dir";

			var de = this.vdman.directories[icnt];
			var r = t.appendChild(document.createElement("tr"));
			r.style.background = "lavender";
			var d = r.appendChild(document.createElement("td"));
			d.innerText = de.VDName;
			d.setAttribute("onclick", "var mya = document.getElementById('" + rid + "'); if(mya.style.display == ''){mya.style.display = 'none';}else{mya.style.display = '';}");
			d.setAttribute("oncontextmenu", this.instancename + ".displaydescriptionform(" + icnt.toString() + ");return false;");

			/*
			d = r.appendChild(document.createElement("td"));
			d.setAttribute("onclick", this.instancename + ".displaymodificationform(" + icnt.toString() + ");");
			d.style.color = "blue";
			d.innerText = "modify";

			d = r.appendChild(document.createElement("td"));
			d.setAttribute("onclick", this.instancename + ".removedirectory(" + icnt.toString() + ");");
			d.style.color = "blue";
			d.innerText = "remove";
			*/

			d = r.appendChild(document.createElement("td"));
			d.setAttribute("onclick", this.instancename + ".displayddtable('" + did + "','" + de.VDID + "');");
			d.style.color = "blue";
			d.innerText = "reload";

			d = r.appendChild(document.createElement("td"));
			d.setAttribute("onclick", this.instancename + ".displaydirectoryform(" + icnt.toString() + ");");
			d.style.color = "blue";
			d.innerText = this.vdman.getdistributeddirectories(de.VDID).length.toString() + " directories";

			d = r.appendChild(document.createElement("td"));
			try
			{
				d.innerHTML = (new StrUtil()).replaceall(de.VDComment, "\n", "<br />");
			}
			catch(err)
			{
				d.innerText = de.VDComment;
			}

			r = t.appendChild(document.createElement("tr"));
			r.setAttribute("id", rid);
			r.style.display = "none";
			d = r.appendChild(document.createElement("td"));
			d.setAttribute("colspan", "5");
			d.setAttribute("id", did);
			this.displayddtable(did, de.VDID);
		}
	}

	this.displayddtable = function(pid, pvdid)
	{
		var dl = this.vdman.getdistributeddirectories(pvdid);
		var vf = new VFiles();
		var fu = new FileUtil();
		for(var icnt = 0; icnt < dl.length; icnt++)
		{
			var de = dl[icnt];
			var fl = fu.getfiles(de.DirectoryPath);
			for(var jcnt = 0; jcnt < fl.length; jcnt++)
			{
				var fe = fl[jcnt];
				vf.add(new VFile(fe.Path));
			}
		}

		var mya = document.getElementById(pid);
		mya.innerHTML = "";
		try
		{
			var t = mya.appendChild(document.createElement("table"));
			t.style.fontSize = "small";
			var r = t.appendChild(document.createElement("tr"));
			r.style.background = "mistyrose";
			var d = r.appendChild(document.createElement("td"));
			d.innerText = "Name";
			d = r.appendChild(document.createElement("td"));
			d.innerText = "LastWriteTime";
			d = r.appendChild(document.createElement("td"));
			d.innerText = "KBSize";
			d = r.appendChild(document.createElement("td"));
			d.innerText = "Size";
			d = r.appendChild(document.createElement("td"));
			d.innerText = "PhysicalDirectory";
			for(var fcnt = 0; fcnt < vf.items.length; fcnt++)
			{
				var myitem = vf.items[fcnt];
				r = t.appendChild(document.createElement("tr"));
				if(fcnt % 2 == 0)
				{
					r.style.background = "lavenderblush";
				}
				d = r.appendChild(document.createElement("td"));
				var anc = d.appendChild(document.createElement("a"));
				anc.setAttribute("href", myitem.filename);
				anc.setAttribute("target", fcnt.toString() + "ftarget" + this.instancename + (new Date()).getTime().toString());
				anc.innerText = myitem.name;

				d = r.appendChild(document.createElement("td"));
				d.innerText = myitem.lastwritetime;
				d = r.appendChild(document.createElement("td"));
				d.setAttribute("align", "right");
				d.innerText = Math.ceil(myitem.filesize / 1024);
				d = r.appendChild(document.createElement("td"));
				d.setAttribute("align", "right");
				d.innerText = myitem.filesize;
				d = r.appendChild(document.createElement("td"));
				anc = d.appendChild(document.createElement("a"));
				anc.setAttribute("href", myitem.directory);
				anc.setAttribute("target", fcnt.toString() + "dtarget" + this.instancename);
				anc.innerText = myitem.directory;
			}
		}
		catch(err)
		{
			mya.innerText = err.message;
		}
	}

	this.displaymodificationform = function(pidx)
	{
		this.closecurtain();
		this.displaycurtain();
		this.displayformarea();
		this.vdcreationform.display(this.vdman.directories[pidx]);
	}

	this.displaycreationform = function()
	{
		this.closecurtain();
		this.displaycurtain();
		this.displayformarea();
		this.vdcreationform.display();
	}

	this.displaydescriptionform = function(pidx)
	{
		this.closecurtain();
		this.displaycurtain();
		this.displayformarea();
		this.vddescriptionform.display(pidx, this.vdman.directories[pidx]);
	}

	this.displaydirectoryform = function(pidx)
	{
		this.closecurtain();
		this.displaycurtain();
		this.displayformarea();
		var myvd = this.vdman.directories[pidx];
		this.vddirectoryform.display(myvd.VDID, myvd.VDName, this.vdman.getdistributeddirectories(myvd.VDID));
	}

	this.displayformarea = function()
	{
		var mydiv = document.body.appendChild(document.createElement("div"));
		mydiv.setAttribute("id", this.formid);
		mydiv.style.position = "absolute";
		mydiv.style.top = "100px";
		mydiv.style.left = "100px";
		mydiv.style.zIndex = 101;

		var mydiv = document.body.appendChild(document.createElement("div"));
		mydiv.setAttribute("id", this.messagedivid);
		mydiv.style.position = "absolute";
		mydiv.style.top = "50px";
		mydiv.style.left = "100px";
		mydiv.style.zIndex = 102;
		var t = mydiv.appendChild(document.createElement("table"));
		var r = t.appendChild(document.createElement("tr"));
		var d = r.appendChild(document.createElement("td"));
		d.style.color = "white";
		d.setAttribute("id", this.messageareaid);
		d.setAttribute("onclick", "document.getElementById('" + this.messageareaid + "').innerHTML = '';");
	}

	this.displaymessage = function(pstr)
	{
		var myd = document.getElementById(this.messageareaid);
		try
		{
			myd.innerHTML = (new StrUtil()).replaceall(pstr, "\n", "<br />");
		}
		catch(err)
		{
			myd.innerText = pstr;
		}
	}

	this.displaycurtain = function()
	{
		var canv = document.body.appendChild(document.createElement("canvas"));
		canv.setAttribute("id", this.curtainid);
		canv.style.position = "absolute";
		canv.style.top = 0;
		canv.style.left = 0;
		canv.style.zIndex = 100;
		canv.width = window.innerWidth;
		canv.height = window.innerHeight;
		var cx = canv.getContext("2d");
		cx.beginPath();
		cx.fillStyle = "rgba(0,0,0,0.7)";
		cx.fillRect(0,0,canv.width, canv.height);
		cx.closePath();
		canv.setAttribute("onclick", this.instancename + ".closecurtain();");
	}
	this.closecurtain = function()
	{
		var ids = new Array();
		ids.length = 0;
		ids[ids.length] = this.curtainid;
		ids[ids.length] = this.formid;
		ids[ids.length] = this.messagedivid;
		for(var icnt = 0; icnt < ids.length; icnt++)
		{
			try
			{
				var mya = document.getElementById(ids[icnt]);
				mya.parentNode.removeChild(mya);
			}catch(err){}
		}
	}
	this.getvaluesfromcreationform = function()
	{
		var ret = this.vdcreationform.getvalues();
		if(ret.name == "")
		{
			this.displaymessage("name is necessary.");
			ret = null;
		}
		return ret;
	}
	this.createdirectoryfromform = function()
	{
		var cont = this.getvaluesfromcreationform();
		if(cont)
		{
			this.vdman.createdirectory(cont.name, cont.comment);
			this.displayfoldertable();
			this.closecurtain();
		}
	}
	this.modifydirectoryfromform = function()
	{
		var cont = this.getvaluesfromcreationform();
		if(cont)
		{
			this.vdman.modifydirectory(cont.vdid, cont.name, cont.comment);
			this.displayfoldertable();
			this.closecurtain();
		}
	}
	this.removedirectory = function(pidx)
	{
		this.vdman.removedirectory(this.vdman.directories[pidx].VDID);
		this.displayfoldertable();
		this.closecurtain();
	}
	this.publishdirectory = function(pidx)
	{
		this.vdman.publishdirectory(this.vdman.directories[pidx].VDID);
		this.displayfoldertable();
		this.closecurtain();
	}
	this.unpublishdirectory = function(pidx)
	{
		this.vdman.unpublishdirectory(this.vdman.directories[pidx].VDID);
		this.displayfoldertable();
		this.closecurtain();
	}
	this.adddistributeddirectory = function(pvdid, pfilepath)
	{
		try
		{
			var fu = new FileUtil();
			var ppath = fu.fso.GetFile(pfilepath).ParentFolder.Path;
			this.vdman.adddistributeddirectory(pvdid, ppath);
			this.displayfoldertable();
			this.closecurtain();
		}
		catch(err)
		{
			try
			{
				this.displaymessage(err.message);
			}
			catch(errr)
			{
				alert(err.message);
			}
		}
	}
	this.removedistributeddirectory = function(pvpid)
	{
		try
		{
			this.vdman.removedistributeddirectory(pvpid);
			this.displayfoldertable();
			this.closecurtain();
		}
		catch(err)
		{
			alert(err.message);
		}
	}
}

var VDDescriptionForm = function(pinstancename, pid)
{
	this.rootid = pid;
	this.handlerinstancename = pinstancename;
	this.display = function(pidx, pobj)
	{
		var mya = document.getElementById(this.rootid);
		var t = mya.appendChild(document.createElement("table"));
		t.style.fontSize = "x-large";
		t.style.color = "white";
		var r = t.appendChild(document.createElement("tr"));
		var d = r.appendChild(document.createElement("td"));
		d.innerText = "Name";
		d = r.appendChild(document.createElement("td"));
		d.innerText = pobj.VDName;

		r = t.appendChild(document.createElement("tr"));
		d = r.appendChild(document.createElement("td"));
		d.innerText = "Description";
		d = r.appendChild(document.createElement("td"));
		try
		{
			d.innerHTML = (new StrUtil()).replaceall(pobj.VDComment, "\n", "<br />");
		}
		catch(err)
		{
			d.innerText = pobj.VDComment;
		}

		r = t.appendChild(document.createElement("tr"));
		d = r.appendChild(document.createElement("td"));
		d.setAttribute("colspan", "3");
		var modifybutton = d.appendChild(document.createElement("input"));
		modifybutton.style.border = "none";
		modifybutton.style.background = "transparent";
		modifybutton.style.color = "white";
		modifybutton.setAttribute("value", "modify");
		modifybutton.setAttribute("type", "button");
		modifybutton.setAttribute("onclick", this.handlerinstancename + ".displaymodificationform(" + pidx.toString() + ");");

		var removebutton = d.appendChild(document.createElement("input"));
		removebutton.style.border = "none";
		removebutton.style.background = "transparent";
		removebutton.style.color = "white";
		removebutton.setAttribute("value", "remove");
		removebutton.setAttribute("type", "button");
		removebutton.setAttribute("onclick", this.handlerinstancename + ".removedirectory(" + pidx.toString() + ");");

		var publishbutton = d.appendChild(document.createElement("input"));
		publishbutton.style.border = "none";
		publishbutton.style.background = "transparent";
		publishbutton.style.color = "white";
		publishbutton.setAttribute("type", "button");
		if(pobj.ForWhom)
		{
			publishbutton.setAttribute("value", "let this public");
			publishbutton.setAttribute("onclick", this.handlerinstancename + ".publishdirectory(" + pidx.toString() + ");");
		}
		else
		{
			publishbutton.setAttribute("value", "let this private");
			publishbutton.setAttribute("onclick", this.handlerinstancename + ".unpublishirectory(" + pidx.toString() + ");");
		}
	}
}

var VDCreationForm = function(pinstancename, pid)
{
	this.rootid = pid;
	this.handlerinstancename = pinstancename;
	this.vdidid = this.rootid + "vdidbox" + (new Date()).getTime().toString();
	this.nameboxid = this.rootid + "namebox" + (new Date()).getTime().toString();
	this.commentboxid = this.rootid + "commentbox" + (new Date()).getTime().toString();
	this.actionbuttonid = this.rootid + "actbutton" + (new Date()).getTime().toString();
	this.display = function(pobj)
	{
		var mya = document.getElementById(this.rootid);
		var t = mya.appendChild(document.createElement("table"));
		t.style.fontSize = "small";
		t.style.color = "white";
		var r = t.appendChild(document.createElement("tr"));
		var d = r.appendChild(document.createElement("td"));
		d.innerText = "Name";
		d = r.appendChild(document.createElement("td"));
		var myi = d.appendChild(document.createElement("input"));
		myi.setAttribute("id", this.nameboxid);
		myi.setAttribute("type", "text");

		r = t.appendChild(document.createElement("tr"));
		d = r.appendChild(document.createElement("td"));
		d.innerText = "Description";
		d = r.appendChild(document.createElement("td"));
		var myi = d.appendChild(document.createElement("textarea"));
		myi.setAttribute("id", this.commentboxid);
		myi.setAttribute("rows", "5");
		myi.setAttribute("cols", "50");

		r = t.appendChild(document.createElement("tr"));
		d = r.appendChild(document.createElement("td"));
		d.setAttribute("colspan", "2");
		myi = d.appendChild(document.createElement("input"));
		myi.style.border = "none";
		myi.style.background = "transparent";
		myi.style.color = "white";
		myi.setAttribute("type", "button");
		myi.setAttribute("value", "ok");
		myi.setAttribute("id", this.actionbuttonid);

		r = t.appendChild(document.createElement("tr"));
		r.style.display = "none";
		d = r.appendChild(document.createElement("td"));
		d.setAttribute("colspan", "2");
		d.setAttribute("id", this.vdidid);

		if(pobj)
		{
			document.getElementById(this.nameboxid).setAttribute("value", pobj.VDName);
			document.getElementById(this.commentboxid).value =  pobj.VDComment;
			document.getElementById(this.actionbuttonid).setAttribute("onclick", this.handlerinstancename + ".modifydirectoryfromform();");
			document.getElementById(this.vdidid).innerText = pobj.VDID;
		}
		else
		{
			document.getElementById(this.actionbuttonid).setAttribute("onclick", this.handlerinstancename + ".createdirectoryfromform();");
		}
	}
	this.getvalues = function()
	{
		var ret = new Array();
		ret.length = 0;
		ret.name = document.getElementById(this.nameboxid).value;
		ret.comment = document.getElementById(this.commentboxid).value;
		ret.vdid = document.getElementById(this.vdidid).innerText;
		return ret;
	}
}

var VDDirectoryForm = function(pinstancename, pid)
{
	this.rootid = pid;
	this.handlerinstancename = pinstancename;
	this.fileid = this.rootid + this.handlerinstancename + (new Date()).getTime().toString();

	this.display = function(pvdid, pname, pl)
	{
		var mya = document.getElementById(this.rootid);
		var gt = mya.appendChild(document.createElement("table"));
		gt.style.fontSize = "small";
		gt.style.color = "white";
		var gr = gt.appendChild(document.createElement("tr"));
		var gd = gr.appendChild(document.createElement("td"));
		gd.innerText = pname;
		gr = gt.appendChild(document.createElement("tr"));
		gd = gr.appendChild(document.createElement("td"));
		var ft = gd.appendChild(document.createElement("table"));
		var fr = ft.appendChild(document.createElement("tr"));
		var fd = fr.appendChild(document.createElement("td"));
		var myi = fd.appendChild(document.createElement("input"));
		myi.setAttribute("type", "file");
		myi.setAttribute("id", this.fileid);

		myi = fd.appendChild(document.createElement("input"));
		myi.style.border = "none";
		myi.style.background = "transparent";
		myi.style.color = "white";
		myi.setAttribute("type", "button");
		myi.setAttribute("value", "add");
		myi.setAttribute("onclick", this.handlerinstancename + ".adddistributeddirectory('" + pvdid + "', document.getElementById('" + this.fileid + "').value);");

		gr = gt.appendChild(document.createElement("tr"));
		gd = gr.appendChild(document.createElement("td"));
		var t = gd.appendChild(document.createElement("table"));
		t.style.fontSize = "small";
		t.style.color = "white";
		if(pl)
		{
			var fu = new FileUtil();
			for(var icnt = 0; icnt < pl.length; icnt++)
			{
				var pe = pl[icnt];
				var r = t.appendChild(document.createElement("tr"));
				var d = r.appendChild(document.createElement("td"));
				d.innerText = pe.DirectoryPath;
				d = r.appendChild(document.createElement("td"));
				var folderexists = fu.fso.FolderExists(pe.DirectoryPath);
				d.innerText = folderexists;
				if(!folderexists)
				{
					d.style.color = "red";
				}
				d = r.appendChild(document.createElement("td"));
				myi = d.appendChild(document.createElement("input"));
				myi.style.border = "none";
				myi.style.background = "transparent";
				myi.style.color = "white";
				myi.setAttribute("type", "button");
				myi.setAttribute("value", "remove");
				myi.setAttribute("onclick", this.handlerinstancename + ".removedistributeddirectory('" + pe.VPID + "');");
			}
		}
	}
}

